/*
 * Copyright © 2017 eqxiu.com 北京中网易企秀科技有限公司  All rights reserved.
 */

package cn.hermit.doclet;

import cn.hermit.util.StringUtils;
import com.sun.javadoc.RootDoc;
import com.sun.tools.doclets.formats.html.HtmlDoclet;

import java.util.Arrays;

/**
 * @author JackGao 高建国
 * @description //TODO 设计说明
 * @date 7/6/2017
 */
public class HtmlDocGenerator extends DocGenerator {

    private String buildDir;

    public HtmlDocGenerator() {
        this(null);
    }

    public HtmlDocGenerator(String[] args) {
        if(args != null && args.length != 0) {
            argumentList.addAll(Arrays.asList(args));
        }
    }

    @Override
    protected void generate(RootDoc root) {
        HtmlDoclet.start(root);
    }

    public void setBuildDir(String buildDir) {
        this.buildDir = buildDir;
        if(!StringUtils.isBlank(buildDir)) {
            argumentList.add("-d");
            argumentList.add(buildDir + "/docs");
        }
    }

    public static void main(String[] args) {
        HtmlDocGenerator generator = new HtmlDocGenerator();
        generator.setSourcePath("/Users/JackGao/eqxiu/ws/user-ws/mylab/examples/dubbo/api/src/main/java");
        generator.setBuildDir("/Users/JackGao/eqxiu/ws/user-ws/mylab/examples/dubbo/api/build");
        generator.generate();
    }
}
